package com.sky.mapper;

//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 李志红
 */
@Mapper
public interface ShoppingCartMapper /*extends BaseMapper<ShoppingCart>*/ {
    /**
     * @param dto 实体类
     * @return 查询结果
     */
    List<ShoppingCart> findAll(ShoppingCartDTO dto);

    void addCart(ShoppingCart cart);

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> getAllCarts(Long userId);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    /**
     * 根据id更新
     * @param shoppingCart
     */
    void updateById(ShoppingCart shoppingCart);

}
